#include<bits/stdc++.h>
using namespace std;
struct z
{
    int st,en;
    bool f;
}qj[100002];
int num;
struct z1
{
    int x,ct;
}p[100002];
int t;
int n,m,l,vm;
int d[100002];
int v[100002],a[100002];
int cnt[1000002];
int ans,ans1;
bool f[1000002];
int ss(int vm,int v0,int aa)
{
    if(vm==v0)
        return 1;
    return ceil(((double)vm*(double)vm-(double)v0*(double)v0)/(double)(2*aa))-1;
}
bool cmp(z1 r,z1 y)
{
    if(r.ct==y.ct)
    return r.x<y.x;
    return r.ct>y.ct;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int i,j,s,tmp;
    bool flg;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d%d",&n,&m,&l,&vm);
        memset(cnt,0,sizeof(cnt));
        memset(f,0,sizeof(f));
        ans=ans1=num=0;
        for(i=1;i<=n;i++)
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(i=1;i<=m;i++)
        {
            scanf("%d",&p[i].x);
            f[p[i].x]=1;
        }
        for(i=1;i<=n;i++)
        {
            flg=0;
            if(v[i]>vm)
            {
                if(a[i]>=0)
                {
                    for(j=d[i];j<=l;j++)
                    {
                        if(f[j])
                        {
                            flg=1;
                            cnt[j]++;
                        }
                    }
                    qj[++num].st=d[i];
                    qj[num].en=l;
                    qj[num].f=0;
                }
                else
                {
                    s=ss(vm,v[i],a[i]);
                    tmp=min(l,d[i]+s);
                    for(j=d[i];j<=tmp;j++)
                    {
                        if(f[j])
                        {
                            flg=1;
                            cnt[j]++;
                        }
                    }
                    qj[++num].st=d[i];
                    qj[num].en=tmp;
                    qj[num].f=0;
                }
            }
            else
            {
                if(a[i]>0)
                {
                    s=ss(vm,v[i],a[i]);
                    if(d[i]+s>l)
                        continue;
                    for(j=d[i]+s;j<=l;j++)
                    {
                        if(f[j])
                        {
                            flg=1;
                            cnt[j]++;
                        }
                    }
                    qj[++num].st=d[i]+s;
                    qj[num].en=l;
                    qj[num].f=0;
                }
            }
            if(flg)
                ans++;
        }
        printf("%d ",ans);
        tmp=0;
        while(tmp<num)
        {
            for(i=1;i<=m;i++)
            p[i].ct=cnt[p[i].x];
            sort(p+1,p+1+m,cmp);
            for(i=1;i<=num;i++)
            {
                if(qj[i].f)
                    continue;
                if(qj[i].st<=p[1].x&&qj[i].en>=p[1].x)
                {
                    tmp++;
                    qj[i].f=1;
                    for(j=qj[i].st;j<=qj[i].en;j++)
                    {
                        if(f[j])
                            cnt[j]--;
                    }
                }
                cnt[p[1].x]=0;
                ans1++;
            }
        }
        printf("%d\n",m-ans1);
    }
    return 0;
}
